﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Wanet.PublicPortal.Common.Domain
{
	public class WebSite:BasePersistentItem
	{
		/// <summary>
		/// Gets a value indicating whether this instance is root.
		/// </summary>
		/// <value><c>true</c> if this instance is root; otherwise, <c>false</c>.</value>
		public virtual bool IsRoot
		{
			get
			{
				return Parent == null;
			}
		}

		/// <summary>
		/// Gets or sets a value indicating whether this page is public.
		/// </summary>
		/// <value><c>true</c> if this page is public; otherwise, <c>false</c>.</value>
		public virtual bool IsPublic
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the URL.
		/// </summary>
		/// <value>The URL.</value>
		public virtual string Url
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the page ID associated to this site.
		/// </summary>
		/// <value>The page ID.</value>
		public virtual int WebPageID
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the sites.
		/// </summary>
		/// <value>The sites.</value>
		public virtual IList<WebSite> Sites
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the parent.
		/// </summary>
		/// <value>The parent.</value>
		public virtual WebSite Parent
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the roles.
		/// </summary>
		/// <value>The roles.</value>
		public virtual IList<Role> Roles
		{
			get;
			set;
		}

		/// <summary>
		/// Gets a value indicating whether this instance has sites.
		/// </summary>
		/// <value><c>true</c> if this instance has sites; otherwise, <c>false</c>.</value>
		public bool HasSites
		{
			get 
			{
				if (Sites == null)
				{
					return false;
				}

				return Sites.Count > 0;
			}
		}

		/// <summary>
		/// Gets or sets the route.
		/// </summary>
		/// <value>The route.</value>
		public virtual WebPageRoute Route
		{
			get;
			set;
		}
	}
}
